# models/medical_history.py
from datetime import datetime
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
from models.base import Base


class MedicalHistory(Base):
    __tablename__ = "medical_history"

    id = Column(Integer, primary_key=True, index=True)
    user_id = Column(Integer, ForeignKey("users.id"), nullable=False)  # 正确关联users表
    title = Column(String(255), index=True, nullable=False)  # 已指定长度（正确）
    # 关键修正：为content添加长度（例如10000，根据实际对话内容长度调整）
    content = Column(String(10000), nullable=False)
    createdAt = Column(DateTime, default=datetime.utcnow, nullable=False)
    updatedAt = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)

